package com.oa.store.manager.oa.leave.impl;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.oa.store.dao.LeaveDao;
import com.oa.store.manager.oa.leave.LeaveManager;
import com.oa.store.model.oa.Leave;

@Service
@Transactional(readOnly = true)
public class LeaveManagerImpl implements LeaveManager {

	@Autowired
	private LeaveDao leaveDao;
	
	@Transactional(readOnly = false)
	public int insertLeave(Leave entity) {
		if(entity.getId() == null){
			entity.setApplyTime(new Date());
		}
		return leaveDao.insertLeave(entity);
	}

	public Leave getLeave(Long id) {
		return leaveDao.getLeave(id);
	}

}
